﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using System.Xml;
using IOEx;
using System.IO;

namespace QuanLyTruong
{
    public partial class frmThongtindangky : DevExpress.XtraEditors.XtraForm
    {
        public Form parentForm = null;

        public frmThongtindangky()
        {
            InitializeComponent();
        }

        private void btnLuu_Click(object sender, EventArgs e)
        {
            try
            {
                if (File.Exists(Application.StartupPath + "\\config.xml"))
                {
                    XmlDocument xd = new XmlDocument();
                    xd.Load(Application.StartupPath + "\\config.xml");

                    XmlNode xNode = xd.SelectSingleNode("connection/ThanhPho");
                    xNode.InnerText = cbTinhthanh.SelectedText;

                    xNode = xd.SelectSingleNode("connection/QuanHuyen");
                    xNode.InnerText = txtQuanhuyen.Text;

                    xNode = xd.SelectSingleNode("connection/PhuongXa");
                    xNode.InnerText = txtPhuongxa.Text;

                    xNode = xd.SelectSingleNode("connection/NgayCaiDatChuongTrinh");
                    xNode.InnerText = DateTime.Now.ToString("dd,MM,yyyy");

                    xNode = xd.SelectSingleNode("connection/LCS");
                    xNode.InnerText = txtMadonvi.Text;

                    xNode = xd.SelectSingleNode("connection/TenUBND");
                    xNode.InnerText = txtDaidienUBND.Text;

                    xNode = xd.SelectSingleNode("connection/TenNganhGiaoDuc");
                    xNode.InnerText = txtDaidienGiaoduc.Text;

                    xNode = xd.SelectSingleNode("connection/TenNguoiLapBang");
                    xNode.InnerText = txtNguoidangky.Text;

                    xd.Save(Application.StartupPath + "\\config.xml");

                    //frmDangkybanquyen parent = (frmDangkybanquyen)parentForm;
                    //parent.DoGenerateAfterFillInFormdangky();
                    this.Close();
                }
            }
            catch (Exception ex) { }
        }

        private void btnThoat_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void frmThongtindangky_Load(object sender, EventArgs e)
        {
            txtNgaydangky.Text = DateTime.Now.ToString("dd-MM-yyyy");
            DriveListEx m_list;
            m_list = new DriveListEx();
            m_list.Load();

            if (m_list.Count > 0)
            {
                txtMadonvi.Text = m_list[0].SerialNumber;
            }
        }
    }
}